package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.mall.lib.domain.enumclass.*;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * Created by HK on 16/10/10.
 * 平台订单表
 */
@Table(name = "mall_order")
@Entity
@DynamicInsert
@DynamicUpdate
public class MallOrder extends IDEntityMall {

    @Column(columnDefinition = "bigint comment '平台id'")
    private Long mallId;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '总金额'")
    private BigDecimal totalAmount;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '折扣金额'")
    private BigDecimal discountTotalAmount = BigDecimal.ZERO;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '实付金额'")
    private BigDecimal actualAmount;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '卡券优惠金额'")
    private BigDecimal couponDiscountAmount;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '源总金额'")
    private BigDecimal oriTotalAmount;
    @Column(columnDefinition = "varchar(100) comment '订单号'")
    private String orderNum;
    @Column(columnDefinition = "varchar(100) comment '收货地址'", name = "address")
    private String shoppingAddress;
    @Column(columnDefinition = "varchar(100) comment '收货人'")
    private String shoppingMan;
    @Column(columnDefinition = "varchar(100) comment '收货人电话号码'")
    private String shoppingManPhone;
    @Column(columnDefinition = "varchar(30) comment '订单状态 x`(\"待支付\"),IN_PAYMENT(\"支付中\"), CANCEL(\"取消\"), PAYED(\"已支付\"), FINISHED(\"已完成\")'")
    @Enumerated(EnumType.STRING)
    private MallOrderStatus status = MallOrderStatus.WAIT_PAYING;
    @Column(columnDefinition = "varchar(30) comment '订单类型 GOODS(\"实物商品\"), SERVICE(\"到店服务\")'")
    @Enumerated(EnumType.STRING)
    private OrderType orderType;
    @Column(columnDefinition = "varchar(255) comment '备注'")
    private String remark;
    @Column(columnDefinition = "bigint comment '客户id'")
    private Long customerId;
    @Column(columnDefinition = "varchar(255) comment '客户名称'")
    private String customerName;
    @Column(columnDefinition = "varchar(30) comment '应用类型：平台或商家'")
    @Enumerated(EnumType.STRING)
    private MallSourceType mallSourceType;
    @Column(columnDefinition = "varchar(30) comment '平台服务费比率'", name = "platform_service_fee_rates")
    private String mallServiceFeeRates;
    @Column(columnDefinition = "varchar(100) comment '支付流水号'")
    private String paymentTransaction;
    @Column(columnDefinition = "varchar(100) comment '礼包名称'")
    private String giftName;
    @Column(columnDefinition = "varchar(100) comment '礼包id'")
    private Long giftId;
    @Column(columnDefinition = "varchar(100) comment '礼包数量'")
    private Long giftNum;
    @Column(columnDefinition = "bigint comment '商家 卡券id'")
    private Long merchantCouponId;
    @Column(columnDefinition = "bigint comment '平台 具体积分卡券id'")
    private Long integrationCouponId;
    @Column(columnDefinition = "bigint comment '平台 积分现金券id'")
    private Long cashCouponId;
    @Column(columnDefinition = "bigint comment '平台 具体积分现金券id'")
    private Long integrationCashCouponId;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '现金券金额'")
    private BigDecimal cashCouponAmount;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '现金券使用后剩余金额'")
    private BigDecimal cashCouponSurplusAmount;
    @Column(columnDefinition = "varchar(100) comment '支付URL'")
    private String payUrl;
    @Column(columnDefinition = "varchar(100) comment '分销码'")
    private String salesCode;
    @Column(columnDefinition = "varchar(30) comment '支付方式 WECHAT(\"微信\"),CASH_COUPON(\"现金券\"),BALANCE(\"余额支付\")'")
    @Enumerated(EnumType.STRING)
    private PaymentMethod paymentMethod;
    @Column(columnDefinition = "varchar(30) comment '下单方式 COMMON(\"普通下单\"),GIFT_PACKET(\"礼包下单\")'")
    @Enumerated(EnumType.STRING)
    private OrderCommitType commitType;
    @Column(columnDefinition = "varchar(30) comment '客户手动退款状态 REFUNDED(\"已退款\"), NOTREFUND(\"未退款\")'")
    @Enumerated(EnumType.STRING)
    private RefundType refundType = RefundType.NOTREFUND;
    @Column(columnDefinition = "bigint comment '平台资金账户ID'")
    private Long mallFundId;
    @Column(columnDefinition = "varchar(100) comment '退款订单号, 申请退款之后才有值'")
    private String refundOrderNum;
    @Column(columnDefinition = "varchar(100) comment '退款流水号, 申请退款之后才有值'")
    private String refundTransaction;
    @Column(columnDefinition = "DECIMAL(30,10) default 0 comment '退款金额, 申请退款之后才有值'")
    private BigDecimal refundAmount;
    @Column(columnDefinition = "varchar(100) comment '退款方式, 申请退款之后才有值'")
    @Enumerated(EnumType.STRING)
    private RefundMethod refundMethod;
    /**
     * 分享返利
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment '分享返利'")
    private BigDecimal shareFee;

    /**
     * 订单来源，WXAPP:微信小程序；WEXIN:公众号H5
     */
    @Column(columnDefinition = "varchar(100) comment '订单来源，WXAPP:微信小程序；WECHAT:公众号H5'")
    @Enumerated(EnumType.STRING)
    private OrderSource orderSource;
    /**
     * M/D分享比率
     */
    @Column(columnDefinition = "DECIMAL(30,10) comment  'M/D分享比率'")
    private BigDecimal shareRate;

    @Column(columnDefinition = "bigint comment '推广码ID'")
    private Long promotionCodeId;

    public static final String CLASS_TITLE = "平台订单";
    public static final String CHECK_ORDER_NUM_IS_NOT_NULL="订单号不能为空";

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getDiscountTotalAmount() {
        return discountTotalAmount;
    }

    public void setDiscountTotalAmount(BigDecimal discountTotalAmount) {
        this.discountTotalAmount = discountTotalAmount;
    }

    public BigDecimal getOriTotalAmount() {
        return oriTotalAmount;
    }

    public void setOriTotalAmount(BigDecimal oriTotalAmount) {
        this.oriTotalAmount = oriTotalAmount;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public String getShoppingAddress() {
        return shoppingAddress;
    }

    public void setShoppingAddress(String shoppingAddress) {
        this.shoppingAddress = shoppingAddress;
    }

    public String getShoppingMan() {
        return shoppingMan;
    }

    public void setShoppingMan(String shoppingMan) {
        this.shoppingMan = shoppingMan;
    }

    public String getShoppingManPhone() {
        return shoppingManPhone;
    }

    public void setShoppingManPhone(String shoppingManPhone) {
        this.shoppingManPhone = shoppingManPhone;
    }

    public MallOrderStatus getStatus() {
        return status;
    }

    public void setStatus(MallOrderStatus status) {
        this.status = status;
    }

    public OrderType getOrderType() {
        return orderType;
    }

    public void setOrderType(OrderType orderType) {
        this.orderType = orderType;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public MallSourceType getMallSourceType() {
        return mallSourceType;
    }

    public void setMallSourceType(MallSourceType mallSourceType) {
        this.mallSourceType = mallSourceType;
    }

    public String getMallServiceFeeRates() {
        return mallServiceFeeRates;
    }

    public void setMallServiceFeeRates(String mallServiceFeeRates) {
        this.mallServiceFeeRates = mallServiceFeeRates;
    }

    public String getPaymentTransaction() {
        return paymentTransaction;
    }

    public void setPaymentTransaction(String paymentTransaction) {
        this.paymentTransaction = paymentTransaction;
    }

    public String getGiftName() {
        return giftName;
    }

    public void setGiftName(String giftName) {
        this.giftName = giftName;
    }

    public Long getGiftId() {
        return giftId;
    }

    public void setGiftId(Long giftId) {
        this.giftId = giftId;
    }

    public Long getGiftNum() {
        return giftNum;
    }

    public void setGiftNum(Long giftNum) {
        this.giftNum = giftNum;
    }

    public String getPayUrl() {
        return payUrl;
    }

    public void setPayUrl(String payUrl) {
        this.payUrl = payUrl;
    }

    public String getSalesCode() {
        return salesCode;
    }

    public void setSalesCode(String salesCode) {
        this.salesCode = salesCode;
    }

    public PaymentMethod getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public OrderCommitType getCommitType() {
        return commitType;
    }

    public void setCommitType(OrderCommitType commitType) {
        this.commitType = commitType;
    }

    public Long getMerchantCouponId() {
        return merchantCouponId;
    }

    public void setMerchantCouponId(Long merchantCouponId) {
        this.merchantCouponId = merchantCouponId;
    }

    public BigDecimal getCouponDiscountAmount() {
        return couponDiscountAmount;
    }

    public void setCouponDiscountAmount(BigDecimal couponDiscountAmount) {
        this.couponDiscountAmount = couponDiscountAmount;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public RefundType getRefundType() {
        return refundType;
    }

    public void setRefundType(RefundType refundType) {
        this.refundType = refundType;
    }

    public Long  getIntegrationCouponId() {
        return integrationCouponId;
    }

    public void setIntegrationCouponId(Long integrationCouponId) {
        this.integrationCouponId = integrationCouponId;
    }

    public Long getIntegrationCashCouponId() {
        return integrationCashCouponId;
    }

    public void setIntegrationCashCouponId(Long integrationCashCouponId) {
        this.integrationCashCouponId = integrationCashCouponId;
    }

    public BigDecimal getActualAmount() {
        return actualAmount;
    }

    public void setActualAmount(BigDecimal actualAmount) {
        this.actualAmount = actualAmount;
    }

    public BigDecimal getCashCouponAmount() {
        return cashCouponAmount;
    }

    public void setCashCouponAmount(BigDecimal cashCouponAmount) {
        this.cashCouponAmount = cashCouponAmount;
    }

    public Long getCashCouponId() {
        return cashCouponId;
    }

    public void setCashCouponId(Long cashCouponId) {
        this.cashCouponId = cashCouponId;
    }

    public BigDecimal getCashCouponSurplusAmount() {
        return cashCouponSurplusAmount;
    }

    public void setCashCouponSurplusAmount(BigDecimal cashCouponSurplusAmount) {
        this.cashCouponSurplusAmount = cashCouponSurplusAmount;
    }

    public Long getMallFundId() {
        return mallFundId;
    }

    public void setMallFundId(Long mallFundId) {
        this.mallFundId = mallFundId;
    }

    public String getRefundOrderNum() {
        return refundOrderNum;
    }

    public void setRefundOrderNum(String refundOrderNum) {
        this.refundOrderNum = refundOrderNum;
    }

    public String getRefundTransaction() {
        return refundTransaction;
    }

    public void setRefundTransaction(String refundTransaction) {
        this.refundTransaction = refundTransaction;
    }

    public BigDecimal getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(BigDecimal refundAmount) {
        this.refundAmount = refundAmount;
    }

    public RefundMethod getRefundMethod() {
        return refundMethod;
    }

    public void setRefundMethod(RefundMethod refundMethod) {
        this.refundMethod = refundMethod;
    }

    public OrderSource getOrderSource() {
        return orderSource;
    }

    public void setOrderSource(OrderSource orderSource) {
        this.orderSource = orderSource;
    }

    public BigDecimal getShareFee() {
        return shareFee;
    }

    public void setShareFee(BigDecimal shareFee) {
        this.shareFee = shareFee;
    }

    public BigDecimal getShareRate() {
        return shareRate;
    }

    public void setShareRate(BigDecimal shareRate) {
        this.shareRate = shareRate;
    }

    public Long getPromotionCodeId() {
        return promotionCodeId;
    }

    public void setPromotionCodeId(Long promotionCodeId) {
        this.promotionCodeId = promotionCodeId;
    }

    @Override
    public String toString() {
        return "MallOrder{" +
                "mallId=" + mallId +
                ", totalAmount=" + totalAmount +
                ", discountTotalAmount=" + discountTotalAmount +
                ", actualAmount=" + actualAmount +
                ", couponDiscountAmount=" + couponDiscountAmount +
                ", oriTotalAmount=" + oriTotalAmount +
                ", orderNum='" + orderNum + '\'' +
                ", shoppingAddress='" + shoppingAddress + '\'' +
                ", shoppingMan='" + shoppingMan + '\'' +
                ", shoppingManPhone='" + shoppingManPhone + '\'' +
                ", status=" + status +
                ", orderType=" + orderType +
                ", remark='" + remark + '\'' +
                ", customerId=" + customerId +
                ", customerName='" + customerName + '\'' +
                ", mallSourceType=" + mallSourceType +
                ", mallServiceFeeRates='" + mallServiceFeeRates + '\'' +
                ", paymentTransaction='" + paymentTransaction + '\'' +
                ", giftName='" + giftName + '\'' +
                ", giftId=" + giftId +
                ", giftNum=" + giftNum +
                ", merchantCouponId=" + merchantCouponId +
                ", integrationCouponId=" + integrationCouponId +
                ", cashCouponId=" + cashCouponId +
                ", integrationCashCouponId=" + integrationCashCouponId +
                ", cashCouponAmount=" + cashCouponAmount +
                ", cashCouponSurplusAmount=" + cashCouponSurplusAmount +
                ", payUrl='" + payUrl + '\'' +
                ", salesCode='" + salesCode + '\'' +
                ", paymentMethod=" + paymentMethod +
                ", commitType=" + commitType +
                ", refundType=" + refundType +
                ", mallFundId=" + mallFundId +
                ", refundOrderNum='" + refundOrderNum + '\'' +
                ", refundTransaction='" + refundTransaction + '\'' +
                ", refundAmount=" + refundAmount +
                ", refundMethod=" + refundMethod +
                ", shareFee=" + shareFee +
                ", orderSource=" + orderSource +
                ", promotionCodeId=" + promotionCodeId +
                ", shareRate='" + shareRate + '\'' +
                '}';
    }
}
